﻿using System;
using System.Data;
using System.Collections.Generic;
using Slja.Model;
namespace Slja.BLL
{
    /// <summary>
    /// EnumBasicDataBLL
    /// </summary>
    public partial class EnumBasicDataBLL
    {
        private readonly Slja.DAL.EnumBasicDataDAL dal = new Slja.DAL.EnumBasicDataDAL();
        public EnumBasicDataBLL()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string Class, string Code)
        {
            return dal.Exists(Class, Code);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Slja.Model.EnumBasicDataModel model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Slja.Model.EnumBasicDataModel model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string Class, string Code)
        {

            return dal.Delete(Class, Code);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Slja.Model.EnumBasicDataModel GetModel(string Class, string Code)
        {

            return dal.GetModel(Class, Code);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }       
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Slja.Model.EnumBasicDataModel> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Slja.Model.EnumBasicDataModel> GetLinkmanType()
        {
            return GetModelList("Class='LinkManType'");
           
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Slja.Model.EnumBasicDataModel> DataTableToList(DataTable dt)
        {
            List<Slja.Model.EnumBasicDataModel> modelList = new List<Slja.Model.EnumBasicDataModel>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Slja.Model.EnumBasicDataModel model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Slja.Model.EnumBasicDataModel();
                    dal.AssignModel(dt.Rows[n], model);                   
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }    

        #endregion  Method
    }
}

